package ro.unibuc.nautilus.controllers;

import java.util.List;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;

import ro.unibuc.nautilus.domain.Harbour;
import ro.unibuc.nautilus.service.HarboursService;

public class HarboursController extends ParameterizableViewController {
	
	HarboursService harboursService;
	
	protected ModelAndView handleRequestInternal(
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        ModelAndView mav = new ModelAndView(getViewName());
        
        List<Harbour> allHarbs = harboursService.findAll();
        Vector<Harbour> harbs = new Vector<Harbour>();
        for (int i = 0; i < 10; i ++) {
        	harbs.add(allHarbs.get(i));
        }
        
        mav.addObject("harbours", harbs);
        return mav;
    }

    @Required
    public void setHarboursService(HarboursService harboursService) {
        this.harboursService = harboursService;
    }
	
}
